package cn.com.jinhao.provider.business.service.impl;


import cn.com.jinhao.provider.business.entity.FlowCount;
import cn.com.jinhao.provider.business.entity.FlowInfo;
import cn.com.jinhao.provider.business.mapper.FlowInfoMapper;
import cn.com.jinhao.provider.business.service.FlowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * HotLine
 * <p>Description: 流程状态服务</p>
 *
 * @author ShaneMew
 * @version 1.0
 * @date 2020/02/17
 * @since 2020/02/17
 */
@Service
public class FlowInfoServiceImpl implements FlowInfoService {
    private FlowInfoMapper flowInfoMapper;

    @Autowired
    public FlowInfoServiceImpl(FlowInfoMapper flowInfoMapper) {
        this.flowInfoMapper = flowInfoMapper;
    }

    @Override
    public int selectCount(String deptCode) {
        return flowInfoMapper.selectCountByDeptCode(deptCode);
    }

    @Override
    public List<FlowCount> queryInfoCountByDeptCode(String deptCode) {
        return flowInfoMapper.queryInfoCountByDeptCode(deptCode);
    }

    @Override
    public List<FlowInfo> queryInfoDetailByDeptCodeAndStatusCode(String deptCode, String statusCode) {
        return flowInfoMapper.queryInfoByDeptCodeAndSatusCode(deptCode, statusCode);
    }

    @Override
    public int add(FlowInfo flowInfo) {
        return flowInfoMapper.insertSelective(flowInfo);
    }

    @Override
    public int update(FlowInfo flowInfo) {
        return flowInfoMapper.updateByPrimaryKey(flowInfo);
    }

    @Override
    public int batchInsert(List<FlowInfo> flowInfos) {
        return flowInfoMapper.insertList(flowInfos);
    }

    @Override
    public FlowInfo queryByEventCode(String eventCode) {
        FlowInfo flowInfo = new FlowInfo();
        flowInfo.setEventCode(eventCode);
        return flowInfoMapper.selectOne(flowInfo);
    }

    @Override
    public FlowInfo findByEventCodeDeptCodeDispatchCode(String deptCode, String dispatchCode, String eventCode) {
        FlowInfo flowInfo = new FlowInfo();
        flowInfo.setEventCode(eventCode);
        flowInfo.setDeptCode(deptCode);
        flowInfo.setDispatchCode(dispatchCode);
        return flowInfoMapper.selectOne(flowInfo);
    }
}
